import React from 'react'
import Movieson from './movieson'
import axios from '../../utils/axios'
import {useState,useEffect} from "react"
import Luo from 'iscroll-luo';
import {useNavigate} from "react-router-dom"
import { ProductCard, Tag, Button } from 'react-vant';
function Movie() {
   let navigate =useNavigate()
   let [arr,setArr] = useState([])

   useEffect(()=>{
    getlist()
   },[])
   let getlist = (isup) =>{
    axios.get("/api/list").then(res=>{
        if (isup === "up") {
            let newarr = JSON.parse(JSON.stringify(arr))
            let newpusharr = [...newarr,...res.data]
            setArr(newpusharr)
        } else {
            setArr(res.data)
        }
       
    })
   }
   let ondown = ()=>{
    getlist()
   }
   let onUp = ()=>{
    getlist("up")
   }
   let goDetail = (item)=>{
        console.log(item);
        navigate("/detail",{
            state:item
        })
   }
  return (
    <div>
        <div style={{ position: 'relative', height: '90vh' }}>
  			<Luo
  				id='id'
  				onDown={ondown}
            	onUp={onUp}
  			>
  				{
           arr && arr.length ? arr.map((item,index)=>{
                return  <ProductCard
                onClick={()=>goDetail(item.detailinfo)}
                num="2"
                price={item.price}
                desc="描述信息"
                title={item.tit}
                thumb={item.img}
                key={index}
              />
           }):""
       }	

  			</Luo>
  		</div>
       
     
    </div>
  )
}

export default Movie